package com.isnmp.common.base;

import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;

public class DataUtils extends ClassLoader {
    static Cipher cipher;

    static {
        try {
            SecureRandom localSecureRandom = new SecureRandom();
            char[] arrayOfChar = { '!', 'z', 'h', 't', 'e', 'l', 'e', 'p', 'r', 'o', '!' };
            System.out.println("new String(arrayOfChar)==" + new String(arrayOfChar));
            System.out.println("===" + System.getProperty(new String(arrayOfChar)));
            //            byte[] arrayOfByte = System.getProperty(new String(arrayOfChar)).getBytes();
            byte[] arrayOfByte = "AlOTPROP".getBytes();
            DESKeySpec localDESKeySpec = new DESKeySpec(arrayOfByte);
            String str = "DES";
            SecretKeyFactory localSecretKeyFactory = SecretKeyFactory.getInstance(str);
            SecretKey localSecretKey = localSecretKeyFactory.generateSecret(localDESKeySpec);
            cipher = Cipher.getInstance(str);
            cipher.init(2, localSecretKey, localSecureRandom);
        } catch (Exception localException) {
            localException.printStackTrace();
        }
    }

    @SuppressWarnings("rawtypes")
    @Override
    protected Class<?> findClass(String paramString) throws ClassNotFoundException {
        try {
            System.out.println("调用findclass了" + paramString);

            Class localClass = null;
            String str1 = paramString.replace(".", "/") + ".class";
            //char[] arrayOfChar = { '!', 'z', 'h', 't', 'e', 'l', 'e', 'p', 'a', 't', '!' };
            //            String str2 = System.getProperty(new String(arrayOfChar));
            String str2 = "uk/zhtelecom/function/";
            str1 = str1.replace("delete/", str2);

            byte[] arrayOfByte1 = FileUtil.readFile(str1);
            System.out.println(str1 + "datautils--arrayOfByte1====" + arrayOfByte1);
            if (arrayOfByte1 != null) {
                byte[] arrayOfByte2 = cipher.doFinal(arrayOfByte1);
                localClass = defineClass(paramString, arrayOfByte2, 0, arrayOfByte2.length);
            }
            return localClass;
        } catch (Exception e) {
            e.printStackTrace();
            throw new ClassNotFoundException(e.getMessage());
        }
    }
}